<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class Install extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'cklist:install';
    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '对IT-cklist初始化安装';

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle(): int
    {
        $this->info('正在优化配置！');
        $this->call('optimize:clear');  //用于清除 Laravel 缓存和优化配置。
        $this->call('admin:publish');
        $this->call('admin:install');
        $this->info('正在配置APP密钥！');
        $this->call('key:generate');     //用于生成新的 APP 密钥
        $this->info('正在初始化基础数据！');
        // 填充菜单
        $this->info('正在初始化菜单！');
        $this->call('db:seed', ['--class' => 'admin_menu']);
        // 填充权限
        $this->info('正在初始化权限！');
        $this->call('db:seed', ['--class' => 'AdminPermissionsTableSeeder']);
        // 填充权限-菜单
        $this->call('db:seed', ['--class' => 'AdminPermissionMenuTableSeeder']);
        //厂商导入
        $this->info('正在初始化系统自带厂商！');
        $this->call('db:seed', ['--class' => 'ManufacturerTableSeeder']);
        //导入配件分类
        $this->info('正在初始化系统自带配件分类！');
        $this->call('db:seed', ['--class' => 'PartCategoryTabSeeder']);
        //导入设备分类
        $this->info('正在初始化系统自带设备分类！');
        $this->call('db:seed', ['--class' => 'CategoryTableSeeder']);
      
    


        $this->info('安装完成！');
        $this->warn('用户名密码都为：admin');

        return 0;
    }
}